<?php
namespace App\Http\Controllers\WebApi\Home;

use App\Services\Admin\OrderBaleService;
use App\Services\Admin\CompanyService;
use App\Services\Admin\StaffService;
use App\Services\Main\AdService;
use Illuminate\Http\Request;

class HomeController extends BaseController
{
    protected $ad; //广告
    protected $bale; //货单
    protected $company; //公司
    protected $facotry; //工厂
    protected $staff; //工厂

    public function __construct()
    {
        parent::__construct();
        $this->ad = new AdService();
        $this->bale = new OrderBaleService();
        $this->company = new CompanyService();
        $this->staff = new StaffService();
    }

    /**
     * 首页信息
     * @return array，订单、公司、工厂、人才
     */
    public function getIndex(Request $request)
    {
        $dataArr = array(
            //获取广告
            'ads' => $this->ad->getWebIndex(),
            //获取订单
            'bales' => $this->bale->getWebIndex(),
            //获取公司
            'coms' => $this->company->getWebFac(),
            //获取工厂
            'facs' => $this->company->getWebFac(),
            //获取人才
            'workers' => $this->staff->getWebIndex(),
        );
        return $this->toJson(0,$dataArr);
    }

    /**
     * 广告数据，显示4个
     */
    public function getIndexAd(Request $request)
    {
        return $this->toJson(0,$this->ad->getWebIndex());
    }

    /**
     * 订单数据，显示4个
     */
    public function getIndexBale(Request $request)
    {
        return $this->toJson(0,$this->bale->getWebIndex());
    }

    /**
     * 公司数据，显示4个
     */
    public function getIndexCom(Request $request)
    {
        return $this->toJson(0,$this->company->getWebCom());
    }

    /**
     * 工厂数据，显示3个
     */
    public function getIndexFac(Request $request)
    {
        return $this->toJson(0,$this->company->getWebFac());
    }

    /**
     * 工人数据，显示3个
     */
    public function getIndexStaff(Request $request)
    {
        return $this->toJson(0,$this->staff->getWebIndex());
    }

    /**
     * 下载接口
     */
    public function getDownload(Request $request)
    {
        $dataArr = [
            [
                'title' => '2019-01-01，版本1.0，更新XXX，下载地址。。。',
                'detail' => '更新内容，修复BUG更新内容，修复BUG；更新内容，修复BUG',
                'link' => '',
            ],
            [
                'title' => '2019-01-01，版本1.0，更新XXX，下载地址。。。',
                'detail' => '更新内容，修复BUG更新内容，修复BUG；更新内容，修复BUG',
                'link' => '',
            ],
        ];
        return $this->toJson(0,$dataArr);
    }
}